//
//  PreviewView.m
//  CamH
//
//  Created by xqiu on 12-8-21.
//  Copyright (c) 2012年 ghu. All rights reserved.
//

#import "UIPreviewView.h"
#import "ImageHelper.h"

#define  MAX_FACE_COUNT 10

@interface UIPreviewView()
{
    NSInteger m_faceCount;
    CGRect m_faceRect[MAX_FACE_COUNT];
    UIImageView *m_pImageFaces[MAX_FACE_COUNT];     
}
@end

@implementation UIPreviewView

- (id)initWithCoder:(NSCoder*)coder
{
    if (self = [super initWithCoder:coder])
    {
        self->m_faceCount = 0;
        for (int i = 0; i<MAX_FACE_COUNT; i++)
        {
            m_pImageFaces[i] = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
            m_pImageFaces[i].hidden = YES;
            [m_pImageFaces[i] setImage: [ImageHelper GetResIconNamed:@"CameraPage_FaceRect.png"]];
            [self addSubview:m_pImageFaces[i]];
        }
    }
    return self;
}

-(void) updateViewWithFaceCount:(int)faceCount faceRects:(CGRect*)rects
{
    int i;
    for (i=0; i<faceCount; i++) {
        m_pImageFaces[i].hidden = NO;
        m_pImageFaces[i].frame = CGRectMake(rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height);
    }
    for (; i<MAX_FACE_COUNT; i++) {
        m_pImageFaces[i].hidden = YES;
    }
}



@end
